#pragma once

#include <string>
#include <unistd.h>

class Channel
{
public:
    Channel(int wfd, pid_t pid) : _wfd(wfd), _pid(pid)
    {
        _name = "Channel -" + std::to_string(wfd) + std::to_string(pid);
    }
    std::string Name()
    {
        return _name;
    }
    void Send(int cmd)
    {
        ::write(_wfd, &cmd, sizeof(cmd));
    }
    void Close()
    {
        ::close(_wfd);
    }
    pid_t Id()
    {
        return _pid;
    }
    int Fd()
    {
        return _wfd;
    }

private:
    int _wfd;
    std::string _name;
    pid_t _pid;
};